import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routeMap = {
  // path : view
  '/': 'Home.vue',
  '/frontendPaging': 'PageTable/frontendPaging/frontendPaging.vue',
  '/frontendPagingDynCol': 'PageTable/frontendPagingDynCol/frontendPagingDynCol.vue',
  '/backendPaging': 'PageTable/backendPaging/backendPaging.vue',
  '/backendPagingDynCol': 'PageTable/backendPagingDynCol/backendPagingDynCol.vue',
  '/frontendPagingDynCol-v2': 'PageTable/frontendPagingDynCol-v2/frontendPagingDynCol.vue',
  '/backendPaging-v2': 'PageTable/backendPaging-v2/backendPaging.vue',
  '/backendPagingDynCol-v2': 'PageTable/backendPagingDynCol-v2/backendPagingDynCol.vue',
  '/dynColAndDrag': 'PageTable/dynColAndDrag/dynColAndDrag.vue'
}

const routes = Object.keys(routeMap).map(key => {
  var view = routeMap[key];
  return {
    path: key, 
    component: () => import(`@/views/${view}`)// import(`${view}`) // Error: Cannot find module
  }
});

const router = new VueRouter({
  routes
})

export default router
